<?php

namespace Common\Model;
use Think\Model\RelationModel;
class Calc_resultModel extends RelationModel {



    protected $_link = array(
        'useranswer_info'=>array(
            'mapping_type' => self::HAS_MANY,
            'class_name'    =>'user_answer',
            'foreign_key' => 'user_id'
        )
    );




    public function deleteReport($uid, $quiz_id)
    {

        $this->where(['calc_result.user_id' => $uid, 'calc_result.quiz_id'=>$quiz_id])->delete();

        M("user_answer")->where(['user_id' => $uid, 'quiz_id' => $quiz_id])->delete();
        return true;

//        $User = $this;
//
//        foreach($userlist as $u){
//            $User->relation(true)->delete($u['uid']);
//        }
//
//
//        $rs['msg'] = '批量删除用户完成！';
//        $rs['code'] = 1;
//
//        return $rs;
        //$this->ajaxReturn($rs);
    }


}